package com.penglecode.dp.creational.factory.abstrac;

import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

public class CommonDAOFactory extends AbstractDAOFactory {

	public static final String DAO_TYPE_JDBC = "jdbc";
	
	public static final String DAO_TYPE_HIBERNATE = "hibernate";
	
	private String daoType;
	
	private static final Map<String,AbstractDAOFactory> daoFactoryMap = new HashMap<String,AbstractDAOFactory>(){
		private static final long serialVersionUID = -4820513117816345783L;
		{
			put(DAO_TYPE_JDBC, new JdbcDAOFactory());
			put(DAO_TYPE_HIBERNATE, new HibernateDAOFactory());
		}
	};
	
	public CommonDAOFactory() {
		super();
		ResourceBundle resourceBundle = ResourceBundle.getBundle("config");
		daoType = resourceBundle.getString("DAO_TYPE");
	}

	public UserDAO getUserDAO() {
		return daoFactoryMap.get(daoType).getUserDAO();
	}

	public ProductDAO getProductDAO() {
		return null;
	}

}
